<?php
$str=curl('http://dianying.114la.com/?kz ');
//echo $str;
$preg='#最新首播.*<!--影视频道全站通发中部通栏广告位 200*150-->#isU';
preg_match($preg,$str,$arr);
//print_r($arr);die;
$pregarr='#<li>.*<a href="(.*)" title=".*" target="_blank">.*<img src="(.*)" title=".*" alt=".*" />.*<div class=".*">.* <h2>(.*)</h2>.*<p>(.*)</p>.*<span class=".*"><b></b></span>.*</div>.*<span><em></em><b>(.*)</b></span>.*<i class=".*"></i>.*<div class=".*"><b></b></div>.*</a>.*</li>#isU';
preg_match_all($pregarr,$arr[0],$arrff);
foreach($arrff[1] as $k=>$value)
{
    $arr_mm['url']=$arrff[1][$k];
    $arr_mm['img']=$arrff[2][$k];
    $arr_mm['title']=$arrff[3][$k];
    $arr_mm['text']=$arrff[4][$k];
    $dbh=new PDO('mysql:host=localhost;dbname=gaofei','root','root');
    $sql="insert into gg (url,img,title,text) VALUES('{$arr_mm['url']}','{$arr_mm['img']}','{$arr_mm['title']}','{$arr_mm['text']}')";
    $dbh->exec($sql);

}
function curl($url)
{
    $ch=curl_init();
    curl_setopt($ch,CURLOPT_URL,$url);
    curl_setopt($ch,CURLOPT_HEADER,0);
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
    curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,false);
    $str=curl_exec($ch);
    return $str;

}

?>